package com.softfly.bigdata.spark;

import org.apache.spark.api.java.function.ForeachFunction;
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
import org.apache.spark.sql.SparkSession;

public class SqlDemo {
    public static void main(String[] args) {
        SparkSession spark = SparkSession
                .builder()
                .appName("sss")
                .master("local")
                .config("spark.sql.files.ignoreCorruptFiles", "true")
                .config("hive.metastore.uris", "thrift://test29:9083")
                .enableHiveSupport()
                .getOrCreate();
        Dataset<Row> ds = spark.sql("select * from mysql__hive__columns_v2 limit 10");
        ds.foreach(new ForeachFunction<Row>() {
            @Override
            public void call(Row row) throws Exception {
                System.out.println(row);
            }
        });

    }
}
